



'============================
' DataFrame RowCount
'============================
Private Sub test_DataFrame_RowCount()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    Debug.Print df.rowCount = 0
    
    df.addRow
    Debug.Print df.rowCount = 1
    df.addRow
    Debug.Print df.rowCount = 2
End Sub

'============================
' DataFrame ColumnCount
'============================
Private Sub test_DataFrame_ColumnCount()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByIndex 5, cTypes:=Array(DF_ColumnType.DF_INT, DF_ColumnType.DF_STRING, _
                                DF_ColumnType.DF_STRING, DF_ColumnType.DF_STRING, _
                                DF_ColumnType.DF_STRING)
    Debug.Print df.columnCount = 5
    
    df.InitByColumnNames Array("c1", "c2", "c3"), cTypes:=Array(DF_ColumnType.DF_INT, DF_ColumnType.DF_STRING, _
                                DF_ColumnType.DF_STRING)
    Debug.Print df.columnCount = 3
End Sub


'============================
' DataFrame addRow
'============================
Private Sub test_DataFrame_addRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    Debug.Print df.rowCount = 0
    
    df.addRow
    Debug.Print df.rowCount = 1
    df.addRow 4
    Debug.Print df.rowCount = 5
End Sub

'============================
' DataFrame getRow
'============================
Private Sub test_DataFrame_getRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    
    Dim row As IDataFrameRow
    Set row = df.getRow(1)
End Sub

'============================
' DataFrame copyRow
'============================
Private Sub test_DataFrame_copyRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    
    df.addRow
    df.setCellValByIndex 1, 1, "aaa"
    df.setCellValByIndex 1, 2, "bbb"
    df.setCellValByIndex 1, 3, "ccc"
    
    Dim newRowNo As Long
    newRowNo = df.copyRow(1)
    Debug.Print newRowNo = 2
    Debug.Print df.getCellValByIndex(2, 1) = "aaa"
    Debug.Print df.getCellValByIndex(2, 2) = "bbb"
    Debug.Print df.getCellValByIndex(2, 3) = "ccc"
    
    df.setCellValByIndex 2, 3, "xxx"
    Debug.Print df.getCellValByIndex(2, 3) = "xxx"
    Debug.Print df.getCellValByIndex(1, 3) = "ccc"
End Sub

'============================
' DataFrame delRow
'============================
Private Sub test_DataFrame_delRow()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow 5
    Debug.Print df.rowCount = 5
    
    df.delRow 2
    df.delRow 2
    Debug.Print df.rowCount = 3
End Sub

'============================
' DataFrame getColByIndex
'============================
Private Sub test_DataFrame_getColByIndex()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    df.addRow 5
    
    Dim col As IDataFrameColumn
    Set col = df.getColByIndex(1)
    col.setCellValByRowIndex 1, "aaa"
    col.setCellValByRowIndex 2, "bbb"
    
    Debug.Print df.getCellValByIndex(1, 1) = "aaa"
    Debug.Print df.getCellValByIndex(2, 1) = "bbb"
End Sub

'============================
' DataFrame getColumnByName
'============================
Private Sub test_DataFrame_getColumnByName()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    df.addRow 5
    
    Dim col As IDataFrameColumn
    Set col = df.getColByName("c1")
    col.setCellValByRowIndex 1, "aaa"
    col.setCellValByRowIndex 2, "bbb"
    
    Debug.Print df.getCellValByIndex(1, 1) = "aaa"
    Debug.Print df.getCellValByIndex(2, 1) = "bbb"
End Sub


'============================
' DataFrame getCellValByIndex
'============================
Private Sub test_DataFrame_getCellValByIndex()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    df.setCellValByIndex 1, 1, "aaa"
    df.setCellValByIndex 1, 2, "bbb"
    df.setCellValByIndex 1, 3, "ccc"
    
    Debug.Print df.getCellValByIndex(1, 1) = "aaa"
    Debug.Print df.getCellValByIndex(1, 2) = "bbb"
    Debug.Print df.getCellValByIndex(1, 3) = "ccc"
    
End Sub

'============================
' DataFrame getCellValByColName
'============================
Private Sub test_DataFrame_getCellValByColName()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    df.setCellValByIndex 1, 1, "aaa"
    df.setCellValByIndex 1, 2, "bbb"
    df.setCellValByIndex 1, 3, "ccc"
    
    Debug.Print df.getCellValByColName(1, "c1") = "aaa"
    Debug.Print df.getCellValByColName(1, "c2") = "bbb"
    Debug.Print df.getCellValByColName(1, "c3") = "ccc"
End Sub

'============================
' DataFrame setCellValByColName
'============================
Private Sub test_DataFrame_setCellValByColName()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    df.setCellValByColName 1, "c1", "aaa"
    df.setCellValByColName 1, "c2", "bbb"
    df.setCellValByColName 1, "c3", "ccc"
    
    Debug.Print df.getCellValByColName(1, "c1") = "aaa"
    Debug.Print df.getCellValByColName(1, "c2") = "bbb"
    Debug.Print df.getCellValByColName(1, "c3") = "ccc"
End Sub

'============================
' DataFrame getRowDescriptor
'============================
Private Sub test_DataFrame_getRowDescriptor()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    Dim rd As IDataFrameDescriptor
    Set rd = df.getRowDescriptor(1)
    
    Debug.Print rd Is Nothing
    
    Set rd = df.getRowDescriptor(1, True)
    Debug.Print Not rd Is Nothing
    
    Set rd = df.getRowDescriptor(1)
    Debug.Print Not rd Is Nothing
End Sub

'============================
' DataFrame getCellDescriptorByIndex
'============================
Private Sub test_DataFrame_getCellDescriptorByIndex()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    Dim cd As IDataFrameDescriptor
    Set cd = df.getCellDescriptorByIndex(1, 2)
    
    Debug.Print cd Is Nothing
    
    Set cd = df.getCellDescriptorByIndex(1, 2, True)
    Debug.Print Not cd Is Nothing
    
    Set cd = df.getCellDescriptorByIndex(1, 2)
    Debug.Print Not cd Is Nothing
End Sub

'============================
' DataFrame getCellDescriptorByColName
'============================
Private Sub test_DataFrame_getCellDescriptorByColName()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3")
    
    df.addRow
    Dim cd As IDataFrameDescriptor
    Set cd = df.getCellDescriptorByColName(1, "c2")
    
    Debug.Print cd Is Nothing
    
    Set cd = df.getCellDescriptorByColName(1, "c2", True)
    Debug.Print Not cd Is Nothing
    
    Set cd = df.getCellDescriptorByColName(1, "c2")
    Debug.Print Not cd Is Nothing
End Sub

'============================
' DataFrame getColTypeByIndex
'============================
Private Sub test_DataFrame_getColTypeByIndex()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3"), cTypes:=Array(DF_ColumnType.DF_INT, DF_ColumnType.DF_STRING, _
                                DF_ColumnType.DF_DOUBLE)
    
    Debug.Print df.getColTypeByIndex(1) = DF_ColumnType.DF_INT
    Debug.Print df.getColTypeByIndex(2) = DF_ColumnType.DF_STRING
    Debug.Print df.getColTypeByIndex(3) = DF_ColumnType.DF_DOUBLE
End Sub

'============================
' DataFrame getColTypeByName
'============================
Private Sub test_DataFrame_getColTypeByName()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3"), cTypes:=Array(DF_ColumnType.DF_INT, DF_ColumnType.DF_STRING, _
                                DF_ColumnType.DF_DOUBLE)
    
    Debug.Print df.getColTypeByName("c1") = DF_ColumnType.DF_INT
    Debug.Print df.getColTypeByName("c2") = DF_ColumnType.DF_STRING
    Debug.Print df.getColTypeByName("c3") = DF_ColumnType.DF_DOUBLE
End Sub


'============================
' DataFrame query
'============================
Private Sub test_DataFrame_query()
    Dim df As DataFrame
    Set df = New DataFrame
    df.InitByColumnNames Array("c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9")
    
    df.addRow
   ' df.setCellValByIndex 1, 1, 123
    df.setCellValByIndex 1, 2, "k1"
    
    df.copyRow 1
    df.setCellValByIndex 2, 2, "k2"
    
    'df.addRow 32000
    Dim ax(0 To 1000000, 0 To 7) As String
    
    
    Dim condition(0) As DFDataCondition
    Set condition(0) = DataFrameHelper.createDFDataConditionForEqual("k1", columnIndex:=2)
    'Set condition(1) = DataFrameHelper.createDFDataConditionForEqual(123, columnIndex:=1)
    Dim result As Variant
    Set result = df.query(condition)
    
End Sub

Private Sub test_other()
    Dim result As DFDataCondition
    result = exec_other(result)
End Sub


Private Function exec_other(ByRef a As Variant) As Variant
    exec_other = a
End Function
